﻿namespace Huayou.UI.WebControls
{
    using System;
    using System.Web.UI;
    using System.Xml;

    internal class MenuGroupNN6 : MenuGroupRenderBase
    {
        public MenuGroupNN6(XmlElement node, WebMenu menu) : base(node, menu)
        {
        }

        public override void RenderEnd(HtmlTextWriter output)
        {
            if (base.IsTopGroup())
            {
                output.RenderEndTag();
            }
            else
            {
                output.RenderEndTag();
                output.Write("</div>");
            }
        }

        public override void RenderHorizontal(HtmlTextWriter output)
        {
            this.RenderStart(output);
            output.RenderBeginTag("tr");
            for (int i = 0; i < base.GroupNode.ChildNodes.Count; i++)
            {
                if ((base.GroupNode.ChildNodes[i].NodeType == XmlNodeType.Element) && (base.GroupNode.ChildNodes[i].Name == "MenuItem"))
                {
                    this.RenderItem(output, base.GroupNode.ChildNodes[i]);
                }
            }
            output.RenderEndTag();
            this.RenderEnd(output);
        }

        public override void RenderItem(HtmlTextWriter output, XmlNode itemNode)
        {
            MenuItemNN6 mnn = new MenuItemNN6((XmlElement) itemNode, this, base.Menu);
            if (mnn.IsVisible)
            {
                mnn.Render(output);
            }
        }

        public override void RenderStart(HtmlTextWriter output)
        {
            string str;
            if (base.IsTopGroup())
            {
                output.AddAttribute("id", base.ClientSideID);
                if (base.useDefaultStyle())
                {
                    output.AddAttribute("class", "aspnmG");
                }
                else if (base.CssClass != null)
                {
                    output.AddAttribute("class", base.CssClass);
                }
                output.AddAttribute("cellspacing", base.ItemSpacing.ToString());
                if (base.Width != null)
                {
                    output.AddAttribute("width", base.Width.ToString());
                }
                if (base.Height != null)
                {
                    output.AddAttribute("height", base.Height.ToString());
                }
                output.AddAttribute("cellpadding", "0");
                output.AddAttribute("border", "0");
                str = string.Concat(new object[] { "aspnm_groupMsOut('", base.ClientSideID, "', null, null, ", base.Menu.ExpandDelay, ", event);" });
                if (base.Menu.Enabled)
                {
                    output.AddAttribute("onmouseout", str);
                }
                output.RenderBeginTag("table");
            }
            else
            {
                output.Write("<div ");
                output.Write("id=\"" + base.ClientSideID + "\" ");
                if (base.useDefaultStyle())
                {
                    output.Write("class=\"aspnmG\" ");
                }
                else if (base.CssClass != null)
                {
                    output.Write("class=\"" + base.CssClass + "\" ");
                }
                string str2 = "aspnm_groupMsOver('" + base.ClientSideID + "')";
                str = ((("aspnm_groupMsOut('" + base.ClientSideID + "', '") + base.GroupNode.ParentNode.Attributes["ClientSideID"].Value + "', '") + base.GroupNode.ParentNode.ParentNode.Attributes["ClientSideID"].Value + "', ") + base.Menu.ExpandDelay.ToString() + ", event)";
                output.Write("style=\"position:absolute;visibility:hidden;z-index:999;top:0px;left0px;\" ");
                if (base.Menu.Enabled)
                {
                    output.Write("onmouseover=\"" + str2 + "\" ");
                    output.Write("onmouseout=\"" + str + "\" ");
                }
                output.Write(">");
                output.AddAttribute("cellspacing", base.ItemSpacing.ToString());
                if (base.Width != null)
                {
                    output.AddAttribute("width", base.Width.ToString());
                }
                if (base.Height != null)
                {
                    output.AddAttribute("height", base.Height.ToString());
                }
                output.AddAttribute("cellpadding", "0");
                output.AddAttribute("border", "0");
                output.RenderBeginTag("table");
            }
        }

        public override void RenderVertical(HtmlTextWriter output)
        {
            this.RenderStart(output);
            for (int i = 0; i < base.GroupNode.ChildNodes.Count; i++)
            {
                output.RenderBeginTag("tr");
                if ((base.GroupNode.ChildNodes[i].NodeType == XmlNodeType.Element) && (base.GroupNode.ChildNodes[i].Name == "MenuItem"))
                {
                    this.RenderItem(output, base.GroupNode.ChildNodes[i]);
                }
                output.RenderEndTag();
            }
            this.RenderEnd(output);
        }
    }
}

